package cn.blnp.net.flowable.boot.tenant;

import cn.blnp.net.flowable.boot.utils.MultiTenantDeployUtil;
import lombok.extern.slf4j.Slf4j;
import org.flowable.engine.IdentityService;
import org.flowable.engine.RepositoryService;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import javax.annotation.Resource;

/**
 * <h3>多租户流程应用案例</h3>
 *
 * @author <a href="mailto:blnp.yibin@qq.com">lyb</a>
 * @version 1.0
 * @since 2025/6/10 10:56
 */
@Slf4j
@SpringBootTest
public class MultiTenantTest {

    @Resource
    private RepositoryService repositoryService;
    @Resource
    private RuntimeService runtimeService;
    @Resource
    private IdentityService identityService;
    @Resource
    private TaskService taskService;
    @Resource
    private MultiTenantDeployUtil multiTenantDeployUtil;

    @Test
    public void test() {
        /**
         *  在不同租户下部署流程定义
         **/
        //租户：OA系统
        multiTenantDeployUtil.deployByTenant(repositoryService, "1894277827809042434", "customEventProcess",
                "flow/customEventProcess.bpmn20.xml");
        //租户：资料系统
        multiTenantDeployUtil.deployByTenant(repositoryService, "1894277827809042437", "customEventProcess",
                "flow/customEventProcess.bpmn20.xml");

        //部署完成后查询不同租户的流程定义信息
        multiTenantDeployUtil.queryProcessDefinitionFromTenant(repositoryService, "1894277827809042434", "customEventProcess");
        multiTenantDeployUtil.queryProcessDefinitionFromTenant(repositoryService, "1894277827809042437", "customEventProcess");
    }
}
